<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/12/16
  Time: 9:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主页</title>
    <script type="text/javascript" src="../../js/jquery-3.6.0.js"></script>
</head>
<body onload="selectUserInfo()">
    <h1 >欢迎你！</h1>
    <button id="btn">检查更新</button>
    <table  border="1" id="testtable">
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>电话号码</th>
            <th>邮箱</th>
            <th>操作</th>
        </tr>
    </table>


</body>
<script type="text/javascript">

        // $("#btn").click(function () {
            function selectUserInfo() {
            $.ajax({
                type:"get",
                url:"/myblog/userinfo/list",
                datatype:"json",
                success : function (data) {
                    var userData = data.page.list;
                    var str = "";
                    for (i = 0;i < userData.length;i++){
                        console.info(userData[i].id+","+userData[i].userName
                                    +"," + userData[i].phone + "," +userData[i].email)
                        str = "<tr><td>"+userData[i].id
                                + "</td><td>"+userData[i].userName
                                + "</td><td>"+userData[i].phone
                                + "</td><td>"+userData[i].email
                                + "</td><td>"+"<a href='#'>添加    </a>"+"<a href='#'>删除    </a>"+"<a href='/sys/edit?id="+userData[i].id+"'>编辑</a>"+"</td></tr>";
                        $("#testtable").append(str);

                    }
                    console.info(data)
                },error:function () {
                    console.info("获取用户信息失败");
                }
            })
            }
        // });
</script>
</html>
